CygNet Studio > Scripting in CygNet Studio > Scripting Examples > Selecting the Current Facility from a List

Selecting the Current Facility from a List

A simple interface can be set up for selecting a facility from a list of facilities in a UIS.

Using the List Box control sets the view’s facility property accordingly and restarts the view.

Note: This functionality can also be achieved using a Facility Navigation Bar.

Using a List Box Control to Enable Selection of a Facility from a UIS Facilities List

  1. Create a new Studio screen.
  2. Add a List Box control to the screen. In its (ObjectCode) field, type "listControl."
  3. Add script to initialize the facility names in the List Box control.
  1. Open the Script Editor and navigate to listControl EventInitialize event.
  2. Enter the following script to manually add facility names to the list box. Replace these names with facilities in the UIS being used.

Sub listFacilities_EventInitialize()

Dim This : Set This = listFacilities

This.AddString("MYFACILITY1")

This.AddString("MYFACILITY2")

This.AddString("MYFACILITY3")

End Sub

  1. Add script to the EventChange event of the List Box control
  1. Navigate to listControl EventChange event.
  2. Enter the following script, which is run when a user changes the selection in the List Box. This script simply assigns the Value property of the list box to the View’s Facility property and restarts the screen.

Sub listFacilities_EventChange()

Dim This : Set This = listFacilities

TheView.Facility = This.Value

TheView.Restart

End Sub

  1. If necessary, set the SiteService property of the View to the UIS service that contains the facilities in the List Box. Save the screen and switch to Run mode. Any other controls placed on the screen that rely on the View’s facility will be updated when the listControl’s selection is changed.

Let us know how we can improve this topic.

CygNet at weatherford.com

© 2020 Weatherford. All rights reserved.